<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<header class="header">
	<nav class="navbar navbar-default" id="navbar">
		<div class="container">
			<div class="header-topbar hidden-xs link-border">
				<ul class="site-nav topmenu">
					<li>
						<a href="/tags.html">标签云</a>
					</li>
					<li>
						<a href="/links.html" rel="nofollow">友情链接</a>
					</li>
					<li>
						<a href="/user/message-board.html" rel="nofollow">问题反馈</a>
					</li>
					<li class="dropdown">
						<a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" rel="nofollow">
							关注本站
							<span class="caret"></span>
						</a>
						<ul class="dropdown-menu header-topbar-dropdown-menu">
							<li>
								<a data-toggle="modal" data-target="#WeChat" rel="nofollow">
									<i class="fa fa-weixin"></i>
									微信
								</a>
							</li>
							<li>
								<a data-toggle="modal" data-target="#areDeveloping" rel="nofollow">
									<i class="fa fa-rss"></i>
									RSS
								</a>
							</li>
						</ul>
					</li>
				</ul>
				<c:if test="${user==null }">
					<a href="/login.html" rel="nofollow">Hi,请登录</a>
					&nbsp;&nbsp;
					<a href="/register.html" class="register" rel="nofollow">我要注册</a>
					&nbsp;&nbsp;
					<a href="" rel="nofollow">找回密码</a>
				</c:if>
				&nbsp;&nbsp;
			</div>
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#header-navbar" aria-expanded="false">
					<span class="sr-only"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<h1 class="logo hvr-bounce-in">
					<a href="${pageContext.request.contextPath }/index.html" title="">
						<img class="top_logo" src="/images/logo.png" alt="">
					</a>
				</h1>
			</div>
			<div class="collapse navbar-collapse" id="header-navbar">
				<ul class="nav navbar-nav navbar-right">
					<li id="category-list" class="hidden-index active">
						<a data-cont="听到微笑的首页" href="/index.html">博客首页</a>
					</li>
					<li class="dropdown visible-xs">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
							其他
							<span class="caret"></span>
						</a>
						<ul class="dropdown-menu">
							<li>
								<a href="${pageContext.request.contextPath }/tags.html">标签云</a>
							</li>
							<li>
								<a href="${pageContext.request.contextPath }/links.html">友情链接</a>
							</li>
							<li>
								<a href="${pageContext.request.contextPath }/notice/list.html">网站公告</a>
							</li>
							<li>
								<a href="${pageContext.request.contextPath }/user/message-board.html">问题反馈</a>
							</li>
						</ul>
					</li>
					<li>
						<c:if test="${user==null }">
							<a href="/login.html" class="visible-xs">登录/注册</a>
						</c:if>
					</li>
					<c:if test="${user!=null }">
						<li class="dropdown">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
								<c:choose>
									<c:when test="${user.imgurl==null || user.imgurl=='' }">
										<img class="headImg" src="/images/icon/icon.png" alt="" />
									</c:when>
									<c:otherwise>
										<img class="headImg" src="${user.imgurl }" alt="" />
									</c:otherwise>
								</c:choose>
								<span class="caret"></span>
							</a>
							<ul class="dropdown-menu" style="min-width: 50px;">
								<li>
									<a href="${pageContext.request.contextPath }/user/user-info.html">个人信息</a>
								</li>
								<li>
									<a href="${pageContext.request.contextPath }/user/collection.html">我的收藏</a>
								</li>
								<li role="separator" class="divider"></li>
								<li>
									<a href="#" onclick="logout()">退出登录</a>
								</li>
							</ul>
						</li>
					</c:if>
				</ul>
				<form class="navbar-form visible-xs" action="/Search" method="post">
					<div class="input-group">
						<input type="text" name="keyword" class="form-control" placeholder="搜索功能暂未开放" maxlength="20" autocomplete="off" disabled="disabled">
						<span class="input-group-btn">
							<button class="btn btn-default btn-search" name="search" type="submit">搜索</button>
						</span>
					</div>
				</form>
			</div>
		</div>
	</nav>
</header>
<!--微信二维码模态框-->
<div class="modal fade user-select" id="WeChat" tabindex="-1" role="dialog" aria-labelledby="WeChatModalLabel">
	<div class="modal-dialog" role="document" style="margin-top:120px;max-width:280px;">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title" id="WeChatModalLabel" style="cursor:default;">微信扫一扫</h4>
			</div>
			<div class="modal-body" style="text-align:center">
				<img src="/images/weixin.png" alt="" style="cursor:pointer;width: 100%" />
			</div>
		</div>
	</div>
</div>
<!--该功能正在日以继夜的开发中-->
<div class="modal fade user-select" id="areDeveloping" tabindex="-1" role="dialog" aria-labelledby="areDevelopingModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title" id="areDevelopingModalLabel" style="cursor:default;">该功能正在日以继夜的开发中…</h4>
			</div>
			<div class="modal-body">
				<img src="/images/baoman/baoman_01.gif" alt="深思熟虑" />
				<p style="padding:15px 15px 15px 100px; position:absolute; top:15px; cursor:default;">很抱歉，程序猿正在日以继夜的开发此功能，本程序将会在以后的版本中持续完善！</p>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-primary" data-dismiss="modal">朕已阅</button>
			</div>
		</div>
	</div>
</div>
<script>
	function logout() {
		$.post(
			"${pageContext.request.contextPath}/account/logout.action",
			function(data) {
				window.location.reload();
			},
			"json"
		);
	}

	$(function() {
		loadCategory(5); //加载分类，参数为分类的个数（5表示，显示不超过5个分类）
	});

	function loadCategory(num) {
		$.post(
			"${pageContext.request.contextPath}/category/index-list.action",
			function(data) {
				var list = data;
				var content = "";
				for (var i = 0; i < list.length && i < num; i++) {
					content += "<li><a href='${pageContext.request.contextPath}/category/" + list[i].alias + ".html'>" + list[i].name + "</a></li>";
				}
				$("#category-list").after(content);
			},
			"json"
		);
	}
</script>
